<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>添加</title>
    <link href="../../layuiadmin/js/adm/css/bootstrap.css" rel="stylesheet">
    <script src="../../layuiadmin/js/adm/js/vue.js"></script>
    <script src="../../layuiadmin/js/adm/js/vue-resource.js"></script>
    <script src="../../layuiadmin/js/adm/js/jquery.min.js"></script>
    <script src="../../layuiadmin/js/adm/js/bootstrap.js"></script>
    <script src="../../layuiadmin/js/adm/js/getUrlParam.js"></script>
    <script src="../../layuiadmin/js/adm/js/date.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui@1.4/lib/theme-default/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui@1.4/lib/index.js"></script>
    <script src="../../layuiadmin/js/adm/js/jquery.cookie.js"></script>
</head>
<body>
    <div id="app" class="container-fluid"  style="margin: 10px 5%" >
        <form class="form-inline">
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#navregister" aria-controls="navregister" role="tab" data-toggle="tab">律师通讯录</a></li>
                <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">外部联系人</a></li>
            </ul>
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="navregister"> <!--  本所 -->
                    <div class="row" style="margin: 20px 0 0 5px">
                        <input type="text" class="form-control" v-model="empname" placeholder="姓名/手机号">
                        <input type="button" @click="postempfurry()" value="检索" class="btn btn-primary">
                    </div>
                    <div class="row" style="margin: 20px 0 0 5px">
                        <table class="table table-condensed table-hover">
                            <thead>
                                <tr>
                                    <th>姓名</th>
                                    <th>出生日期</th>
                                    <th>手机号</th>
                                    <th>固定电话</th>
                                    <th>传真</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr v-for="item in emp">
                                    <td>{{item.empName}}</td>
                                    <td>{{item.empBirthdate}}</td>
                                    <td>{{item.empPhone}}</td>
                                    <td>--</td>
                                    <td>--</td>
                                    <td>{{item.empWorkstatus}}</td>
                                    <td><button type="button" @click="postselect(item.empId)" class="btn btn-default btn-xs">查看</button></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                </div>
                <div role="tabpanel" class="tab-pane" id="profile">        <!-- //外所 -->
                    <div class="row" style="margin: 20px 0 0 5px">
                        <input type="text" class="form-control" v-model="aname" placeholder="单位/部门/手机/姓名">
                        <input type="button" value="检索" @click="addressfurry()" class="btn btn-primary">&nbsp;&nbsp;&nbsp;
                        <input type="button" value="添加联系人" class="btn btn-default" @click="insert()">
                    </div>
                    <div class="row" style="margin: 20px 0 0 5px">
                        <table class="table table-condensed table-hover">
                            <thead>
                                <tr>
                                    <th>单位名称</th>
                                    <th>部门</th>
                                    <th>职位</th>
                                    <th>联系人</th>
                                    <th>手机号码</th>
                                    <th>固定电话</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr v-for="item in address">
                                    <td>{{item.addressUnit}}</td>
                                    <td>{{item.addressDepartment}}</td>
                                    <td>{{item.addressPosition}}</td>
                                    <td>{{item.addressName}}</td>
                                    <td>{{item.addressPhone}}</td>
                                    <td>{{item.addressDecide}}</td>
                                    <td>
                                        <div class="dropdown">
                                            <button class="btn btn-default dropdown-toggle btn-xs" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                                更多
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
                                                <li><a href="#" @click="postaddressselect(item.addressId)">查看</a></li>
                                                <li><a href="#" @click="postdelete(item.addressId)">删除</a></li>
                                                <li><a href="#" @click="postupdate(item.addressId)">修改</a></li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    

    <script>
          var vm=new Vue({
            el:'#app',
            data:{
                emp:[],
                empname:"",
                aname:"",
                address:[]
            },
            methods: {
                postempinfo(){
                    this.$http.post('http://localhost:8080/address/empinfo',{},{emulateJSON:true}).then(resutl =>{
                        var dat=eval("("+resutl.body+")")
                        if(dat!=null&&dat!=""){
                            this.emp=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.emp.push(dat[i])
                            }
                        }else{
                            this.open2()
                        }
                    })
                },
                postempfurry(){
                    this.$http.post('http://localhost:8080/address/empfurry',{"empname":this.empname},{emulateJSON:true}).then(resutl =>{
                        var dat=eval("("+resutl.body+")")
                        if(dat!=null&&dat!=""){
                            this.emp=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.emp.push(dat[i])
                            }
                        }else{
                            this.open2()
                        }
                    })
                },
                postselect(id){
                    window.location.href="addressquery.html?id="+id;
                },
                postempaddressinfo(){
                    this.$http.post('http://localhost:8080/address/addressinfo',{},{emulateJSON:true}).then(resutl =>{
                        var dat=eval("("+resutl.body+")")
                        if(dat!=null&&dat!=""){
                            this.address=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.address.push(dat[i])
                            }
                        }else{
                           this.open2()
                        }
                    })
                },
                postdelete(id){
                    this.$http.post('http://localhost:8080/address/addressdelete',{"id":id},{emulateJSON:true}).then(resutl =>{
                        this.open3()
                        this.postempaddressinfo()
                    })
                },
                postaddressselect(id){
                    window.location.href="addressselect.html?id="+id;
                },
                postupdate(id){
                    window.location.href="addressupdate.html?id="+id;
                },
                insert(){
                    location.href="addressinsert.html";
                },
                addressfurry(){
                    this.$http.post('http://localhost:8080/address/addressfurry',{"aname":this.aname},{emulateJSON:true}).then(resutl =>{
                        var dat=eval("("+resutl.body+")")
                        if(dat!=null&&dat!=""){
                            this.address=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.address.push(dat[i])
                            }
                        }else{
                           this.open2()
                        }
                    })
                },
                open2() {
                    this.$message({
                        showClose: true,
                        message: '未获取到值',
                        type: 'error'
                    });
                },
                open3() {
                    this.$message({
                        showClose: true,
                        message: '删除成功',
                        type: 'success'
                    });
                }
            },
            created () {
                this.postempinfo();
                this.postempaddressinfo();
            }
        })      
    </script>

</body>
</html>